const app = getApp();

Page({

  data: {
    show: false,
    logoUrl: 'http://dwz.date/eSw3', //logo地址
  },

  onLoad(options) {
    wx.showLoading({
      title: '加载中...',
      mask: true
    });
    const userInfo = app.globalData.userInfo;
    console.log(userInfo);
    if (userInfo) { //以前授权过
      wx.switchTab({
        url: '../daily/daily'
      });
    }else{
      wx.hideLoading();
      this.setData({
        show: true
      });
    }

  },

  onShow() {},

  //点击授权，获取用户信息
  getUserProfile(e) {
    wx.getUserProfile({
      desc: '展示用户信息',
      success: (res) => {
        const userInfo = res.userInfo; //获取用户信息
        userInfo.createTime = Date.now(); //授权的时间
        console.log(userInfo);
        app.globalData.userInfo = userInfo;  //存入全局变量
        wx.setStorageSync('userInfo', userInfo); //存入缓存中
        wx.switchTab({
          url: '../daily/daily'
        });
      }
    });
  },

  //分享
  onShareAppMessage() {

  }

})